package com.stock.stockprediction.controller;

import com.stock.stockprediction.entity.User;
import com.stock.stockprediction.utils.R;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/vue-element-admin/user")
public class UserController {
    @PostMapping("/login")
    public R login(@RequestBody User user){
        Map<String,String> map = new HashMap<>();
        map.put("token","admin-token");
        return R.ok()
                .data("token","admin-token");
    }

    @GetMapping("/info")
    public R info(String token){
        System.out.println(token);
        return R.ok()
                .data("roles","[admin]")
                .data("introduction","I am a super administrator")
                .data("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif")
                .data("name","Super Admin");
    }

    @GetMapping("/test/{token}")
    public R test(@PathVariable("token") String token){
        System.out.println(token);
        return R.ok();
    }
}
